package cn.javass.chapter6.web.controller.paramtype;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("myajax.do")
public class AjaxRequestController {

	@RequestMapping(params = "method=test1", method = RequestMethod.GET)
	//加上@ResponseBody，表示返回的处理是ajax请求
	public @ResponseBody List<User> test1(String uname) throws Exception {
		String uname2 = new String(uname.getBytes("iso8859-1"), "gbk");
		System.out.println(uname2);
		System.out.println("MyAjaxController.test1()");
		List<User> list = new ArrayList<User>();
		list.add(new User("高淇", "123"));
		list.add(new User("马士兵", "456"));

		return list;
	}

}
